package com.deco.back.controller.product;

import java.util.List;

import javax.jws.WebParam;
import javax.servlet.http.HttpServletRequest;

import com.free.common.vo.PageResponseVo;
import com.free.common.vo.PageSearchVo;
import com.free.ext.shiro.SessionManager;
import com.free.ext.web.spring.annoation.PageSearch;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.deco.domain.vo.fix.FixGeneralVo;
import com.deco.domain.vo.fix.FixTypeVo;
import com.deco.domain.vo.product.PartsCategoryVo;
import com.deco.domain.vo.product.PartsInfoItemVo;
import com.deco.domain.vo.product.PartsInfoVo;
import com.deco.service.fix.FixGeneralService;
import com.deco.service.fix.FixTypeService;
import com.deco.service.product.PartsCategoryService;
import com.deco.service.product.PartsInfoItemService;
import com.deco.service.product.PartsInfoService;
import com.free.common.vo.ResultModel;

import org.springframework.web.servlet.ModelAndView;

/**
 * 广告管理 Controller
 * @author lengy
 *
 */
@Controller
public class PartsInfoItemController {
    @Autowired
    private PartsInfoItemService partsInfoItemService;

    @Autowired
    private PartsInfoService partsInfoService;
    
    @RequestMapping(value = "/parts_info_item_list.do")
    public ModelAndView listPage(){
        ModelAndView mv = new ModelAndView("prod/partsinfoitemlist");
        List<PartsInfoVo> partsList =  partsInfoService.getAll();
        mv.addObject("partsInfoList", partsList);
        return mv;
    }

    @RequestMapping(value= "/parts_info_item_list_page.do")
    @ResponseBody
    public PageResponseVo<PartsInfoItemVo> getList(@PageSearch PageSearchVo<PartsInfoItemVo> condition){
        return partsInfoItemService.pageInfo(condition);
    }

    @RequestMapping(value = "/parts_info_item_edit.do")
    public ModelAndView editPage(Integer id){
    	PartsInfoItemVo vo = null;
        ModelAndView mv = new ModelAndView("prod/partsinfoitemedit");
        if(id != null){
            vo = partsInfoItemService.getPartsInfoItem(id);
            mv.addObject("actNm","更新");
        }else{
            vo = new PartsInfoItemVo();
            vo.setId(0);
            mv.addObject("actNm","新增");
        }
        
        List<PartsInfoVo> partsList =  partsInfoService.getAll();
        mv.addObject("partsInfoList", partsList);
        mv.addObject("obj",vo);
        return mv;
    }

    @RequestMapping(value ="/parts_info_item_del.do")
    @ResponseBody
    public ResultModel batchDelete(@RequestParam(value = "ids[]")Integer[] ids){
        return partsInfoItemService.batchDelete(ids);
    }

    @RequestMapping(value ="/parts_info_item_edit_submit.do")
    @ResponseBody
    public ResultModel udpate(PartsInfoItemVo vo){
        return partsInfoItemService.save(vo);
    }

    @RequestMapping(value ="/parts_info_item_status.do")
    @ResponseBody
    public ResultModel updateStatus(PartsInfoItemVo vo){
        return partsInfoItemService.save(vo);
    }

}
